package main.java.DMDE.persistence;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import main.java.DMDE.model.*;

import main.java.common.IXmlManager;

public class ModifierXmlManager implements IXmlManager<Modifier> {

	public Element getElementFromItem(Modifier type, Document document) {
		Element typeElement = document.createElement("modifier");
		typeElement.setAttribute("desc", type.getDesc());
		return typeElement;
	}

	@Override
	public Modifier getItemFromXmlElement(Element element) throws Exception {
		String modifier = element.getAttribute("desc");
		if (modifier.equals(Modifier.ABSTRACT.getDesc()))
			return Modifier.ABSTRACT;
		if (modifier.equals(Modifier.FINAL.getDesc()))
			return Modifier.FINAL;
		if (modifier.equals(Modifier.STATIC.getDesc()))
			return Modifier.STATIC;
		return null;
	}
}
